let isbn = null;

function checkISBN() {
    let formData = new FormData();
    formData.append("ISBN", isbn);
    $.ajax({
        type: "POST",
        url: "/api/book/u/checkISBN",
        dataType: "text",
        data: formData,
        processData: false,
        contentType: false,
        success: data => {
            data = eval('('+ data +')');
            if (data.success) {
                gotoAddBook();
            }else {
                alert(data.msg);
            }
        },
        error: function (xhr, textStatus, errorThrown) {
            const msg = xhr.responseText;
            console.log(msg);
        }
    })
}

function gotoAddBook() {
    $("div.detail-con-box").hide();
    $("#app").show();
}

$(document).ready(function () {
    $("a.next-btn").click(function() {
        isbn = $("input[name='isbn_next']").val();
        checkISBN();
    })
})